[IA64] Support grant_table v2 for XENMAPSPACE_grant_table
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 22 Feb 2010 10:08:10 +0000 (10:08 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 22 Feb 2010 10:08:10 +0000 (10:08 +0000)
This patch is ia64 counter part of 20281:95ea2052b41b.
This fixes the issue that HVM domains with PV-on-HVM drivers panic.

Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
xen/arch/ia64/xen/mm.c

index 461a38e151bef648e90bd69fbb42ae572cd8b3e1..bcaadba8e55c4f339a30ffe3285c0cb3b4ec26be 100644 (file)
@@ -3338,12 +3338,25 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
         case XENMAPSPACE_grant_table:
             spin_lock(&d->grant_table->lock);
 
-            if ((xatp.idx >= nr_grant_frames(d->grant_table)) &&
-                (xatp.idx < max_nr_grant_frames))
-                gnttab_grow_table(d, xatp.idx + 1);
+            if (d->grant_table->gt_version == 0)
+                d->grant_table->gt_version = 1;
 
-            if (xatp.idx < nr_grant_frames(d->grant_table))
-                mfn = virt_to_mfn(d->grant_table->shared_raw[xatp.idx]);
+            if (d->grant_table->gt_version == 2 &&
+                (xatp.idx & XENMAPIDX_grant_table_status))
+            {
+                xatp.idx &= ~XENMAPIDX_grant_table_status;
+                if (xatp.idx < nr_status_frames(d->grant_table))
+                    mfn = virt_to_mfn(d->grant_table->status[xatp.idx]);
+            }
+            else
+            {
+                if ((xatp.idx >= nr_grant_frames(d->grant_table)) &&
+                    (xatp.idx < max_nr_grant_frames))
+                    gnttab_grow_table(d, xatp.idx + 1);
+
+                if (xatp.idx < nr_grant_frames(d->grant_table))
+                    mfn = virt_to_mfn(d->grant_table->shared_raw[xatp.idx]);
+            }
 
             spin_unlock(&d->grant_table->lock);
             break;